package mapSystem.interaction;

import java.awt.Graphics;
import java.awt.image.BufferedImage;

import tools.GameElement;
import tools.Rect;


public class TileAction {

	protected BufferedImage image;
	protected double x; 
	protected double y;
	protected GameElement element;
	
	protected boolean visible;
	
	protected boolean selfActivatable;
	protected boolean playerActivatable;
		
	public TileAction() {
		image = null;
		x = -1;
		y = -1;
		element = null;
		
		visible = false;
		
		selfActivatable = false;
		playerActivatable = false;
	}
	public TileAction(double xx, double yy, int xt, int yt, BufferedImage img, GameElement e, int act) {
		x = xx;
		y = yy;
		image = img;
		e.getRect().x = xt;
		e.getRect().y = yt;
		element = e;
		
		visible = true;
		
		selfActivatable = false;
		playerActivatable = true;
		
		if(act == 0) playerActivatable = false;
	}	
	
	// podem ser ativados pisando, por outras actions ou pelo player
	// portanto deve haver diferenca (no caso de por outras actions
	// e considerado autoActivate)
	public GameElement autoActivate(){		
		return null;
	}
	public GameElement playerActivated(){
		if(playerActivatable) return element;
		return null;
	}
	public int getX()
	{
		return (int)x;
	}
	public int getY()
	{
		return (int)y;
	}
	
	public void changeVisible()
	{
		visible = !visible;
	}
	
	public void render(Graphics g, Rect cam)
	{
		if(image != null && visible)
		{
			g.drawImage(image, (int)(x - cam.x), (int)(y - cam.y), null);
		}
	}
	public GameElement simpleActivate() {
		return element;
	}
}
